const Model = require('../prototype/Model')

class UserLogModel extends Model {
  constructor ({ mongodbConnector, collectionName, dbName }) {
    super({ mongodbConnector, collectionName, dbName })
  }

  /**
   * 新增一条用户日志
   * @param {UserLogSchema} docs
   * @param {*} [options]
   * @returns {*}
   */
  insertOne (docs, options) {
    // 补充默认字段
    docs.status = docs.status || 0 // 日志默认为未处理状态
    return super.insertOne(docs, options)
  }

  markFinishedById (id) {
    return this.updateById(id, {
      $set: {
        status: 2
      }
    })
  }
}

module.exports = UserLogModel
